#pragma once
#include "SSLType.hpp"
#include <string>
#include <vector>

namespace ssl
{
    class SSLConfig
    {
        private:
        std::string _certFile;                  // 证书文件路径
        std::string _keyFile;                   // 私钥文件路径
        std::string _chainFile;                 // 证书链文件路径
        SSLVersion _version;                    // SSL/TLS版本
        std::string _ciphers;                   // 加密套件
        bool _verifyClient;                     // 是否验证客户端证书
        int _verifyDepth;                       // 验证证书链的深度
        int _sessionTimeout;                    // 会话超时时间
        long _sessionCacheSize;                 // 会话缓存大小
    public:
        SSLConfig();
        ~SSLConfig() = default;


        //证书配置
        void setCertFile(const std::string &certFile)
        {
            _certFile = certFile;
        }
        //私钥配置
        void setPrivateKeyFile(const std::string &keyFile)
        {
            _keyFile = keyFile;
        }
        //证书链配置
        void setCertificateChainFile(const std::string &chainFile)
        {
            _chainFile = chainFile;
        }
        //协议版本配置
        void setProtocolVersion(SSLVersion version)
        {
            _version = version;
        }
        //加密套件配置
        void setCipherList(const std::string &ciphers)
        {
            _ciphers = ciphers;
        }
        //客户端证书验证配置
        void setVerifyClient(bool verifyClient)
        {
            _verifyClient = verifyClient;
        }
        //客户端证书验证深度配置
        void setVerifyDepth(int verifyDepth)
        {
            _verifyDepth = verifyDepth;
        }
        //会话超时时间配置
        void setSessionTimeout(int sessionTimeout)
        {
            _sessionTimeout = sessionTimeout;
        }
        //会话缓存大小配置
        void setSessionCacheSize(long sessionCacheSize)
        {
            _sessionCacheSize = sessionCacheSize;
        }


        // get系列
        const std::string &getCertFile() const
        {
            return _certFile;
        }
        const std::string &getPrivateKeyFile() const
        {
            return _keyFile;
        }
        const std::string &getChainFile() const
        {
            return _chainFile;
        }
        SSLVersion getProtocolVersion() const
        {
            return _version;
        }
        const std::string &getCipherList() const
        {
            return _ciphers;
        }
        bool getVerifyClient() const
        {
            return _verifyClient;
        }
        int getVerifyDepth() const
        {
            return _verifyDepth;
        }
        int getSessionTimeout() const
        {
            return _sessionTimeout;
        }
        long getSessionCacheSize() const
        {
            return _sessionCacheSize;
        }
    };
}

ssl::SSLConfig::SSLConfig():
    _version(SSLVersion::TLS_1_2),
    _ciphers("HIGH:!aNULL:!MD5"),
    _verifyClient(false),
    _verifyDepth(4),
    _sessionTimeout(300),
    _sessionCacheSize(20480L)
{
}
